package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.config.MinioConstantProperties;
import com.atguigu.tingshu.album.service.AlbumInfoService;
import com.atguigu.tingshu.common.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Tag(name = "上传管理接口")
@RestController
@RequestMapping("api/album")
public class FileUploadApiController {


    @Autowired
    private AlbumInfoService albumInfoService;


    /**
     * 上传文件接口
     * @return  回显地址Url
     */
    /*  /api/album/fileUpload   */
    @Operation(summary = "上传文件")
    @PostMapping("/fileUpload")
    public Result<String> uploadFile(@RequestPart("file") MultipartFile file, HttpServletResponse  response) {


       String url =  albumInfoService.uploadFile(file);

       return Result.ok(url);


    }

}
